﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyGame.Models
{
    /// <summary>
    /// 块的状态
    /// </summary>
    enum BlockStatus
    {
        Blank,
        Black,
        White,
    }
    /// <summary>
    /// 块对象
    /// </summary>
    class Block
    {
        /// <summary>
        /// 状态
        /// </summary>
        public BlockStatus Status { get; set; }
        /// <summary>
        /// 矩阵坐标
        /// </summary>
        public Point Point { get; set; }
        public Block()
        {
            //初始状态为空白
            Status = BlockStatus.Blank;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="point">矩阵坐标，注意它和物理坐标是反的</param>
        public Block(Point point)
        {
            //初始状态为空白
            Status = BlockStatus.Blank;
            Point = point;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="x">矩阵X</param>
        /// <param name="y">矩阵Y</param>
        public Block(int x,int y)
        {
            //初始状态为空白
            Status = BlockStatus.Blank;
            Point = new Point(x,y);
        }
        /// <summary>
        /// 画出当前格子
        /// </summary>
        /// <param name="g">绘图句柄</param>
        /// <param name="rec">当前block的rectangle</param>
        public void Draw(Graphics g,Rectangle rec)
        {
            switch (Status)
            {
                case BlockStatus.Black:
                    g.DrawImage(Properties.Resources.Black, rec);
                    break;
                case BlockStatus.White:
                    g.DrawImage(Properties.Resources.White, rec);
                    break;
              
            }
        }

        /// <summary>
        /// 处理鼠标点击，改变当前块的颜色
        /// </summary>
        /// <param name="IsBlack"></param>
        public void MouseDown(bool IsBlack)
        {
            if (IsBlack)
                this.Status = BlockStatus.Black;
            else
                this.Status = BlockStatus.White;
        }

        public static implicit operator Block(Point v)
        {
            throw new NotImplementedException();
        }
    }
}
